<!doctype html>
<html  class="x-admin-sm">
<head>
	<meta charset="UTF-8">
	<title>VIP用户（登录）</title>
    <link rel="stylesheet" href="css/login.css">
    <script src="js/jquery-3.4.1.js"></script>
    <script>
        function login(){
            let username = document.getElementById("username").value;
            let password = document.getElementById("password").value;
            if (username == ""){
                let use = document.getElementById("return");
                use.innerHTML = "账号不能为空";
            }else if (password == ""){
                let use = document.getElementById("return");
                use.innerHTML = "密码不能为空";
            }else {
                let use = document.getElementById("return");
                use.innerHTML = "";
                $.post({
                    url:"/login",
                    data:{"username":username,"password":password},
                    success:function (data){
                        if (data.toString() == "true"){
                            let ret = document.getElementById("return");
                            ret.innerHTML = "成功校验账号密码,3秒后跳转···";
                            setTimeout(go,3000);

                        }else {
                            console.log("fallse")
                            let ret = document.getElementById("return");
                            ret.innerHTML = "账号或密码错误";
                        }
                    }
                });
            }

        }
        function registered(){
            location.href="registered.html";
        }

        function go(){

            location.href="http://localhost:8080/web/mailSuccess.html"
        }
    </script>
</head>
<body class="login-bg">

    <div class="login">
        <div class="message">会员登录</div>
        <div id="darkbannerwrap"></div>
        <input id="username" name="username" placeholder="用户名"
               type="text" lay-verify="username" class="layui-input" >
        <hr class="hr15">
        <input id="password" name="password" placeholder="密码"
               lay-verify="passwd"  type="password" class="layui-input">
        <hr class="hr15">
        <hr class="hr15">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit" onclick="login()">
        <hr class="hr20" >
        <span id="return" style="color: red;width: 150px;margin: 0"></span>
        <button id="registered" type="submit" onclick="registered()">注册</button>
    </div>

</body>
</html>